const express = require('express');
const router = express.Router();
const shopController = require('../controllers/shop.controller');
const { authMiddleware, adminMiddleware } = require('../middlewares/auth.middleware');

// 公开路由
// 获取所有店铺，支持筛选和搜索
// GET /api/shops?keyword=苹果&category=手机数码&type=official&...
router.get('/', shopController.getAllShops);

// 获取店铺详情
// GET /api/shops/123
router.get('/:id', shopController.getShopById);

// 获取店铺商品
// GET /api/shops/123/products?category=手机&page=1&limit=10
router.get('/:id/products', shopController.getShopProducts);

// 需要登录的路由
router.use(authMiddleware);

// 创建店铺
// POST /api/shops
router.post('/', shopController.createShop);

// 关注/取消关注店铺
// POST /api/shops/123/follow
router.post('/:id/follow', shopController.toggleFollowShop);

// 店主或管理员权限路由
// 更新店铺信息
// PUT /api/shops/123
router.put('/:id', shopController.updateShop);

// 删除店铺
// DELETE /api/shops/123
router.delete('/:id', shopController.deleteShop);

// 获取店铺统计信息
// GET /api/shops/123/stats
router.get('/:id/stats', shopController.getShopStats);

module.exports = router;
